package com.cskaoyan.controller;

import com.cskaoyan.bean.BaseRespVo;
import com.cskaoyan.bean.GenericData;
import com.cskaoyan.bean.param.BaseParam;
import com.cskaoyan.bean.po.MarketComment;
import com.cskaoyan.service.CommentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("admin/comment")
public class CommentController {

    @Autowired
    CommentService commentService;

    //http://182.92.235.201:8083/admin/comment/list?page=1&limit=20&userId=1&valueId=1181044&sort=add_time&order=desc
    // 请求方法: GET
    @GetMapping("list")
    public BaseRespVo list(BaseParam param,Integer userId,Integer valueId) {
        GenericData comments = commentService.query(param, userId, valueId);
        return BaseRespVo.ok(comments);
    }

    @PostMapping("delete")
    public BaseRespVo delete(@RequestBody MarketComment comment){
        Integer delete = commentService.deleteById(comment);
        if (delete == 0) {
            return BaseRespVo.invalidData("订单不存在");
        }
        BaseRespVo respVo = BaseRespVo.ok(null);
        respVo.setErrmsg("成功");
        return respVo;
    }



}
